# Contributor: Vince Mele <vmele@inoc.com>
# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Vince Mele <vmele@inoc.com>
pkgname=sssd
pkgver=1.16.3
pkgrel=8
pkgdesc="System Security Services Daemon"
url="https://pagure.io/SSSD/sssd"
arch="x86_64"
license="GPL-3.0-or-later"

# TODO: the full test suite depends on these
#	but does not pass.
#checkdepends="
#	check-dev
#	cmocka-dev
#	"

depends="
	bind
	curl
	cyrus-sasl-gssapiv2
	"
makedepends="
	autoconf
	gettext-dev
	automake
	libtool
	popt-dev
	talloc-dev
	tdb-dev
	tevent-dev
	ldb-dev
	ding-libs-dev
	linux-pam-dev
	pcre-dev
	c-ares-dev
	bind-tools
	http-parser-dev
	curl-dev
	jansson-dev
	glib-dev
	dbus-dev
	libxslt
	libxml2-utils
	docbook-xsl
	python3-dev
	nss-dev
	openldap-dev
	krb5-dev
	keyutils-dev
	"
subpackages="$pkgname-dev $pkgname-openrc"
source="https://releases.pagure.org/SSSD/sssd/sssd-$pkgver.tar.gz
	0001-makefile.patch
	0002-src.patch
	0003-alpine.patch
	UTIL-Fix-compilation-with-curl-7.62.0.patch
	nss.h
	cifsidmap.h
	"
prepare() {
	default_prepare
	cp "$srcdir"/nss.h "$srcdir"/cifsidmap.h "$builddir"/src/
	autoreconf -i
}

build() {
	./configure \
		--prefix=/usr \
		--sbindir=/usr/sbin \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--libexecdir=/usr/lib/sssd \
		--datadir=/usr/share \
		--enable-pammoddir=/usr/lib/security \
		--with-pid-path=/run \
		--with-initscript=sysv \
		--with-init-dir=/etc/init.d \
		--with-os=alpine \
		--without-selinux \
		--without-semanage \
		--without-autofs \
		--without-ssh \
		--without-samba \
		--without-nfsv4-idmapd-plugin \
		--without-manpages \
		--disable-cifs-idmap-plugin \
		--disable-static \
		--disable-rpath \
		--without-python2-bindings
	make
}

check() {
	make check
}

package() {
	make -j1 DESTDIR="$pkgdir" install

	# Remove files we don't want to package
	find "$pkgdir" -name '*.la' -delete
	find "$pkgdir" -name '*.pyc' -delete
	find "$pkgdir" -name '*.egg-info' -delete

	# pkgdir will allways be set, so silence shellsheck warning:
	#    SC2115: Use "${var:?}" to ensure this never expands to /usr/share .
	# shellcheck disable=SC2115
	rm -r "$pkgdir"/usr/share
	rm -r "$pkgdir"/run
}

sha512sums="6165923f652f624bbe3ddc625ae682c4867eb7a20652d0cf74bbb8dda2307c917d3189ede26fd21a4fb5fd5926149271a65fa09f3affe928029ed99e6422b728  sssd-1.16.3.tar.gz
a330383e7a334db47baf3f42cbb487c4875894e2120f55e71e2846d3d835ad9702137c93a4d233a237b944fb17410ed90b7fa374126f70db77259c0b83741ebc  0001-makefile.patch
573b6ce0eb8ac7b819a895e32f5feb1150f60c4e6ce45c3262b5af862245c968c85f4eef8b62b0e56c8ef12ca5742f368ee12b794942aeabf2bf32d1bf18bd53  0002-src.patch
1ec5048cbb0e184ca52e970b1a0bb0f69aeb647edfcf25610e51ff54e45e77e93a19c2cf22e12a768a474eba7eed8d9a41f7cfd2cbd0ba1495c1002170e77765  0003-alpine.patch
4e846befc5321d4d0db9dc619ca30017629471c20247363a45348f9e56b395a973a1fe991ecba0f0adca1b80cfa788b239f50b24a15c3451fa681782e05d2477  UTIL-Fix-compilation-with-curl-7.62.0.patch
5abb1ffd1302eaa25736404ae148c0ffdeb7ce42fa2745be3436e887a2aa96b9620287f19b2790cb59cbccc2c04a9dee1adec4fa8e813d322cde82793500e33b  nss.h
b88d4f1ba847477783b43542f1248881d4fb8e8a0d4165c65c358fcb442891d2cc7c96b05e2a8e7c05fdc17ecd76f16295c1ffac3f1c9bfd0375c5e65e56201d  cifsidmap.h"
